package com.tedu.servlet;

import com.tedu.entity.Emp;
import com.tedu.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(value = "/emp/all")
public class QueryAllEmpServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //调用业务逻辑
        EmpServiceImpl empService = new EmpServiceImpl();
        List<Emp> emps = empService.findAllEmp();
        request.setAttribute("emps", emps);
        //跳转
        request.getRequestDispatcher("/ems/emp/emplist.jsp").
                forward(request, response);
    }
}
